#include "Rp2WaterEffect.h"
using namespace Rp2;

RP2_IMPLEMENT_RTTI(Rp2, WaterEffect, ShaderEffect);
RP2_IMPLEMENT_DEFAULT_NAME_ID(WaterEffect, ShaderEffect);

//---------------------------------------------------------------------------------------------------
WaterEffect::WaterEffect(const char* acBumpName, const char* acWaterName,
        const char* acEnvName)
	:
	ShaderEffect(1)
{
    m_kVShader[0] = new VertexShader("RipplingOcean");
    m_kPShader[0] = new PixelShader("RipplingOcean");	

    m_kPShader[0]->SetTexture(0,acBumpName);
    m_kPShader[0]->SetTexture(1,acWaterName);
    m_kPShader[0]->SetTexture(2,acEnvName);

    Texture* pkBump = m_kPShader[0]->GetTexture(0);
    pkBump->SetFilterType(Texture::LINEAR);
    pkBump->SetWrapType(0,Texture::REPEAT);
    pkBump->SetWrapType(1,Texture::REPEAT);

    Texture* pkWater = m_kPShader[0]->GetTexture(1);
    pkWater->SetFilterType(Texture::LINEAR);
    pkWater->SetWrapType(0,Texture::CLAMP);
    pkWater->SetWrapType(1,Texture::CLAMP);

    Texture* pkEnv = m_kPShader[0]->GetTexture(2);
    pkEnv->SetFilterType(Texture::LINEAR);

    VertexProgram* pkVProgram = m_kVShader[0]->GetProgram();
    pkVProgram->GetUserConstant("LightDir")->SetDataSource(m_afLightDir);
    pkVProgram->GetUserConstant("WaveDirX")->SetDataSource(m_afWaveDirX);
    pkVProgram->GetUserConstant("WaveDirY")->SetDataSource(m_afWaveDirY);
    pkVProgram->GetUserConstant("WaveSpeed")->SetDataSource(m_afWaveSpeed);
    pkVProgram->GetUserConstant("WaveOffset")->SetDataSource(m_afWaveOffset);
    pkVProgram->GetUserConstant("WaveHeight")->SetDataSource(m_afWaveHeight);
    pkVProgram->GetUserConstant("BumpSpeed")->SetDataSource(m_afBumpSpeed);
    pkVProgram->GetUserConstant("Constants")->SetDataSource(m_afConstants);
}
//---------------------------------------------------------------------------------------------------
WaterEffect::~WaterEffect()
{
}
//---------------------------------------------------------------------------------------------------